import tushare as ts


def get_real_quotes(codes):
    df = ts.get_realtime_quotes(codes)
    if df is None:
        return

    df[df == ''] = 0
    df['b1_p'] = df.b1_p.astype(float)
    df = df[df.b1_p > 0]  # 过滤停牌退市
    if df.empty:
        return

    df['pre_close'] = df.pre_close.astype(float)
    df['price'] = df.price.astype(float)
    df['open'] = df.open.astype(float)
    df['high'] = df.high.astype(float)
    df['low'] = df.low.astype(float)
    df['b1_v'] = df.b1_v.astype(float)
    df['b2_p'] = df.b2_p.astype(float)
    df['b2_v'] = df.b2_v.astype(float)
    df['b3_p'] = df.b3_p.astype(float)
    df['b3_v'] = df.b3_v.astype(float)
    df['b4_p'] = df.b4_p.astype(float)
    df['b4_v'] = df.b4_v.astype(float)
    df['b5_p'] = df.b5_p.astype(float)
    df['b5_v'] = df.b5_v.astype(float)
    df['a1_p'] = df.a1_p.astype(float)
    df['a1_v'] = df.a1_v.astype(float)
    df['a2_p'] = df.a2_p.astype(float)
    df['a2_v'] = df.a2_v.astype(float)
    df['a3_p'] = df.a3_p.astype(float)
    df['a3_v'] = df.a3_v.astype(float)
    df['a4_p'] = df.a4_p.astype(float)
    df['a4_v'] = df.a4_v.astype(float)
    df['a5_p'] = df.a5_p.astype(float)
    df['a5_v'] = df.a5_v.astype(float)
    df['volume'] = df.volume.astype(float) / 100
    df['amount'] = df.amount.astype(float)
    return df
